home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / hc / windoid3.sit / windoid #3.TXT
Encoding:
Text File  |  1988-11-29  |  19.0 KB  |  462 lines  |  [TEXT/MACA]

  1. WINDOID
  2. Issue  #3
  3. The Publication for the Informed HyperCard User
  4. Editor:  David Leffler
  5.  
  6.  
  7. Contents:
  8. INTRODUCTION
  9. EDITOR'S CHOICE
  10. HYPERCARD USER TIPS
  11. UNIVERSAL IMPORT BUTTON
  12. WHOOPS!
  13. THE FORM
  14.  
  15. In this third issue of WINDOID, we will continue to cover importing text into HyperCard. Gary Bond, one of Apples outstanding HyperCard test team members, wrote a universal import button that takes into consideration nearly everything. You can now create a button that imports MacWrite, Microsoft Word, many database files, and even HyperCard stacks! We think you are going to enjoy this.  Phil Wyman, another excellent Apple HyperCard tester, has provided us with more of his highly acclaimed power-user tips and has taken a stab at explaining some of the more interesting aspects of HyperCard properties. In the two previous issues, there were some mistakes. I would like to apologize for any inconvenience or frustration they might have caused and rectify them.  The errata will appear on page seven under WHOOPS. I generally get all the text stuffed into the WINDOID newsletter moments before the Thursday meeting, and
  16. sometimes I miss something. Many of the excellent scripters that avidly read WINDOID have noticed my lapses and have provided me with needed repairs. For their kind assistance, I offer my thanks.
  17.  
  18. WINDOID provides an opportunity for its readers to contribute to the ongoing growth and excellence of HyperCard. With your assistance we can continue to bring to HyperCard added depth and functionality. In the back of every issue will be a form for you to keep by your Macintosh. This form will allow you the unique opportunity to participate directly in the continued development of HyperCard.
  19.  
  20. We will read all the forms returned and address questions that are being asked by HyperCard users. We will ask the team and provide you with an answer and publish the answers in this newsletter.  In this way we can gather information and provide for your needs in future versions of HyperCard.
  21.  
  22. WINDOID is trying to make a difference in the way that you work with HyperCard.  We need your input.  What sort of stacks are you using, what kinds of stacks are you creating, and what are some of the joys and frustrations you are experiencing.  We really want to know!
  23.  
  24. If you have a bug, suggestion, comment, or just want to know the best way to do something in HyperCard, you can fill out the form and send it to:
  25.  
  26. AHUG c/o David Leffler
  27. Apple Computer, Inc.
  28. MS/27-AQ
  29. 20525 Mariani Ave.
  30. Cupertino, CA 95014
  31.  
  32. Or copy the format and Apple-Link it to:  HYPERBUG$
  33.  
  34.  
  35. EDITOR'S CHOICE
  36. by  David Leffler
  37.  
  38.  
  39. At the last Apple HyperCard User Group meeting , Danny Goodman, author of The Complete HyperCard Handbook, presented to an appreciative audience his incredible business productivity stack Focal Point. It will be released soon by Activision. We were all amazed at the incredible graphics and awesome features he has scripted into it. Danny, as you might know, is not a programmer and has always been frustrated by his inability to turn his ideas into software. HyperCard has empowered him to not only turn his ideas into reality, but to allow him the opportunity to share his ideas with the world. Thank you Danny!
  40.  
  41. Amanda Goodenough, author of the Inigo and My Favorite Camel series of
  42. wonderful adventures, was also on hand. Her obvious love of stories and great presentation style captivated the audience.  Amanda continues to enhance and produce more of these non-textual stories and has graciously allowed us to place them in an Amandas Stacks folder on the AHUG StackWare server.  My Favorite Camel is a favorite of mine, and I think everyone should see it and share it with someone they love.
  43.  
  44. There are two other stacks on the StackWare server that also deserve serious attention. The AIDS stack is a perfect representation of how HyperCard can be used in an incredibly invocative eye and heart grabbing style. This stack is not only visually and emotionally gripping, but is an excellent  example of how to use HyperCard as a powerful vehicle to move you through diverse information.  You should get this stack.
  45.  
  46. Finally, Tree Frog Studio software presents CheapSequencer.  Tree Frog has given us a music sequencer that must be seen and heard to be believed. These innovative stackware developers are interested in entertaining us with great
  47. graphics and functional stackware tools.  Its stacks and people like these that really show the power and versatility of HyperCard.
  48.  
  49.  
  50. POWERUSERS TIPS
  51. by Phil Wyman
  52.  
  53.  
  54. 1.  If you get tired of pulling the Tools Windoid off of the menubar when you need it, try Option-Tab, which will tear it off for you!  Also, if the Tools Windoid is in a paint tool,  hitting Tab will tear off the Patterns Windoid.
  55.  
  56. 2.  If you have a line in your script that is longer than the editor window,
  57. you can place an Option-Return at a space in the line to break it into two
  58. smaller lines.  The two lines will execute in the same way as the original
  59. line.  (Do not place the Option-Return into the middle of a quoted string.
  60. Also, if you use the Option-Return in a comment,  remember that every line of a comment must start with a double hyphen!)
  61.  
  62. 3.  For those programmers out there who are used to for next loops, there is a next repeat command in HyperTalk which works in a repeat loop a lot like a next command in a for next loop.  The next repeat command does not
  63. execute anything that follows it in the repeat loop, but rather starts
  64. executing at the beginning of the repeat loop.  Also, if you wish to exit the repeat loop altogether, without executing anymore of the lines in  the repeat loop, then use exit repeat.
  65.  
  66. Note:
  67. If you want to exit the entire message handler from anywhere in the handler, use exit <handlername> (i.e., exit mouseup).
  68. If you wish to leave the handler but wish the current message to be sent on up the hierarchical path from where it is now, then use pass <handlername>.
  69.  
  70. 4.  When concatenating two strings,  you can add a space between the two strings by using two ampersands && instead of just one &.
  71.  
  72. 5.  A shorthand for button in HyperTalk is btn.  A shorthand for background is bkgnd.
  73.  
  74. 6.  You can copy buttons, fields, backgrounds or cards between stacks.  This is a very powerful feature of HyperCard.
  75.  
  76. 7.  For those of you with the regular size Mac Plus or Mac SE screens, try this for a thrill:
  77.       Set loc of cardWindow to 10,50
  78. You will see what people on large screens see all the time, a window title bar which states the pathname of the window you are viewing.  (To reset your cardWindow, Set loc of cardWindow to 0,0.)
  79.  
  80. 8.  If you are in any tool other than the Browse tool, you can return to the Browse tool by Command-Tab.
  81.  
  82. 9.  When you are in the Button tool, you can Command-Drag to create a new
  83. button.  Option-Drag on a button and you will drag a copy of the button.
  84.  
  85. 10.  A first attempt at a small treatise on the use of the,of, and () in HyperTalk:
  86.  
  87. In general, either the, of, or parentheses () are required to signal HyperTalk that a function or property is to be activated.
  88.  
  89.  
  90. PROPERTIES:
  91. With button, card, background, stack, and window properties, the is optional, but you need of. Also, properties never have parentheses. You can say:
  92.    put hilite of button 1
  93.    put the hilite of button 1
  94.  
  95. Since there is no of to activate it, you cannot say:
  96.       put the hilite button 1
  97.  
  98. If you are using a global or painting property, you need the, since there is
  99. no of to activate the property. For instance, you can say:
  100.    put the lockScreen
  101.    put the textAlign
  102.  
  103. However, you cannot put the property by saying:
  104.    put lockScreen
  105. because HyperCard will think you are using lockScreen as a variable, not a
  106. property.
  107.  
  108. FUNCTIONS:
  109.  
  110. Either the, of, or parentheses () are required with a function.
  111.  
  112. However, you cannot mix the with parentheses in a system function. For
  113. instance, you cannot say:
  114.    put the charToNum(a)
  115.  
  116.  You are allowed to say:
  117.    put the chartonum of a
  118.    put chartonum(a)
  119.    put the chartonum of (a)
  120.    If a system function has more than one argument, it will always require
  121. parentheses.  For user-defined functions, you must always use parentheses, even if there are no argumentsi.e., userFunction().  If a function does not use of or (), then the is required! For example, date doesnt work without the, since there is not an of or () to activate the function. You can say:
  122.      put the date
  123.  
  124. But you cannot say:
  125.      put date
  126. because HyperTalk will assume that date is a variable. This concept of
  127. insisting on a the to activate the function allows for future expansion of
  128. more system functions, since system functions will not be able to collide with variables that users already have in their scripts.
  129.  
  130.  
  131. The UNIVERSAL IMPORT BUTTON
  132. by Gary Bond
  133. Rev. 2.2
  134.  
  135.  
  136. Last issue we dealt with importing text. While those approaches are reliable,
  137. they are also very slow and dont account for a number of problems that might
  138. occur along the way. Consistent with our goal to provide you with the best,
  139. this issue contains a script for a universal import button which does both
  140. kinds of import (text and data). To use it, type it into any button script.
  141.  
  142. In addition to importing text files it also imports Macwrite and Word documents
  143. and even Hypercard stacks! This version of the import button fixes bugs both in
  144. Hypercard and in previous button versions.
  145.  
  146. on mouseUp
  147.   global cardcount,startcard,memory,header
  148.   get userlevel
  149.   put it into item 1 of memory
  150.   set userlevel to 5
  151.   set lockmessages to true
  152.   set lockscreen to true
  153.   put short id of this card into startcard
  154.   answer Import text file as: with Data or Text or Cancel
  155.   if it is Cancel then Cleanexit
  156.   if it is Text then
  157.     answer Include header information in fields? with Yes or No
  158.     put it into header
  159.     Importext
  160.   else
  161.     Importdata
  162.   end if
  163.   go next card
  164.   Cleanexit Compact
  165. end mouseup
  166.  
  167. on importext
  168.   global cardcount,startcard,memory,header
  169.   put 0 into cardcount
  170.   repeat
  171.     ask Name or pathname of text file to import: with item 2 of memory
  172.     if short name of this stack is in it then
  173.       if , is not in memory then put , after memory
  174.       put it into item 2 of memory
  175.       answer Cant import current stack! with Ok
  176.       next repeat
  177.     end if
  178.     if it is empty then
  179.       Cleanexit
  180.     else
  181.       exit repeat
  182.     end if
  183.   end repeat
  184.   put it into filename
  185.   if , is not in memory then put , after memory
  186.   put it into item 2 of memory
  187.   set cursor to 4
  188.   open file filename
  189.   repeat
  190.     read from file filename for 16384
  191.     if it is empty and cardcount is 0 then
  192.       answer Could not find file:  & filename with Ok
  193.       close file filename
  194.       Cleanexit
  195.     end if
  196.     if it is empty then exit repeat
  197.     put return after it
  198.     domenu New card
  199.     add 1 to cardcount
  200.     domenu New field
  201.     set name of card field (number of card fields) to Import
  202.     set style of card field Import to scrolling
  203.     drag from the loc of card field Import to 0,62
  204.     drag from 190,100 to 512,342
  205.     if header is Yes then
  206.       put Characters: && number of chars in it & return & return before it
  207.       put Lines: && number of lines in it & return before it
  208.       put File: && filename & return before it
  209.       put Import card: && cardcount & return before it
  210.     end if
  211.     put it into card field Import
  212.   end repeat
  213.   close file filename
  214.   if header is Yes then
  215.     repeat until the short id of this card is startcard
  216.       put  of && cardcount after line 1 of card field Import
  217.       go previous card
  218.     end repeat
  219.   else
  220.     go card id startcard
  221.   end if
  222. end importext
  223.  
  224. on importdata
  225.   global filename,cardcount,startcard,memory,header
  226.   put empty into delimiters
  227.   put empty into filename
  228.   put 0 into cardcount
  229.   put 0 into limit
  230.   put 0 into fieldcount
  231.   repeat until delimiters is not empty
  232.     put 0 into nofields
  233.     answer Use Tab and Return as delimiters? with Yes or Other or
  234. Cancel
  235.     if it is Cancel then mouseup
  236.     if it is Yes then put 9,13 into delimiters
  237.     if it is Other then
  238.       repeat until ((item 1 of it > 0 and item 1 of it < 256)
  239.         and (item 2 of it > 0 and item 2 of it < 256)) or it is empty
  240.         ask Enter two comma separated Ascii delimiters: with empty
  241.         put it into delimiters
  242.       end repeat
  243.     end if
  244.   end repeat
  245.   if item 1 of delimiters is item 2 of delimiters then put 1 into nofields
  246.   answer Include header information in fields? with Yes or No
  247.   put it into header
  248.  repeat
  249.     ask Name or pathname of text file to import: with item 2 of memory
  250.     if short name of this stack is in it then
  251.       if , is not in memory then put , after memory
  252.       put it into item 2 of memory
  253.       answer Cant import current stack! with Ok
  254.       next repeat
  255.     end if
  256.     if it is empty then
  257.       if cardcount > 0 then
  258.         close file filename
  259.         CleanExit
  260.       end if
  261.       Importdata
  262.     else
  263.       exit repeat
  264.     end if
  265.   end repeat
  266.   put it into filename
  267.   if , is not in memory then put , after memory
  268.   put it into item 2 of memory
  269.   set cursor to 4
  270.   open file filename
  271.   repeat
  272.     read from file filename until (numtochar of item 2 of delimiters)
  273.     if it is empty and cardcount is 0 then
  274.       answer Could not find file:  & filename with Ok
  275.       close file filename
  276.       Cleanexit
  277.     end if
  278.     if it is empty then exit repeat
  279.     if chartonum(last character of it) is not item 2 of delimiters then
  280.       put item 2 of delimiters into temp
  281.       if temp is 9 then put Tab into temp
  282.       if temp is 13 then put Return into temp
  283.       answer Cant find record delimiter:  && temp with Ok
  284.       close file filename
  285.       cleanexit
  286.     end if
  287.     put empty into last character of it
  288.     if (numtochar of item 1 of delimiters) is not in it and nofields is 0 then
  289.       put item 1 of delimiters into temp
  290.       if temp is 9 then put Tab into temp
  291.       if temp is 13 then put Return into temp
  292.       answer Cant find field delimiter:  && temp with Help or Ok
  293.       if it is help then
  294.         answer Use double record delimiters for records... with Continue
  295.         answer with no field delimiters. Example: 13,13 with Ok
  296.       end if
  297.       close file filename
  298.       Cleanexit
  299.     end if
  300.     if (numtochar of item 1 of delimiters) is not , and nofields is 0 then
  301.       repeat until (numtochar of item 1 of delimiters) is not in it
  302.         put , into character offset((numtochar of item 1 of delimiters),it) of it
  303.       end repeat
  304.     end if
  305.     if cardcount is 0 then
  306.       domenu New background
  307.     else
  308.       domenu New card
  309.     end if
  310.     add 1 to cardcount
  311.     if nofields is 0 then
  312.       put the number of items in it into limit
  313.     else
  314.       put nofields into limit
  315.     end if
  316.     repeat with count = 1 to limit
  317.       if cardcount is 1 then
  318.         add 1 to fieldcount
  319.         if fieldcount < 125 then
  320.           domenu New field
  321.         else
  322.           answer No more fields can be created! with Ok
  323.           Cleanexit Compact
  324.         end if
  325.       end if
  326.       put Field & count into fieldname
  327.       set name of bkgnd field (number of bkgnd fields) to fieldname
  328.       set style of bkgnd field fieldname to scrolling
  329.       If nofields is 0 and header is Yes then
  330.         put Field && count && of && the number of items in it & return into bkgnd┬ field fieldname
  331.         put Record && cardcount && of file: && filename & return & return after┬ bkgnd field fieldname
  332.       end if
  333.       if nofields is 0 then
  334.         put item count of it & return after bkgnd field fieldname
  335.       else
  336.         put it & return after bkgnd field fieldname
  337.       end if
  338.     end repeat
  339.     choose browse tool
  340.   end repeat
  341.   close file filename
  342.   go card id startcard
  343. end importdata
  344.  
  345. on Cleanexit var
  346.   global memory
  347.   if param(1) is compact then
  348.     domenu Compact stack
  349.   end if
  350.   choose browse tool
  351.   set userlevel to item 1 of memory
  352.   set lockscreen to false
  353.   set lockmessages to false
  354.   exit to hypercard
  355. end Cleanexit
  356.  
  357. We hope that this script will aid in your productivity with HyperCard.  Please
  358. let us know how you like it.
  359.  
  360.  
  361. WHOOPS
  362. by David Leffler
  363.  
  364.  
  365. An errata from the first two issues of WINDOID.
  366.  
  367. ISSUE #1:
  368.  
  369. In the first issue Gary Bond showed us how to find out which line of a scrolling field the user has clicked on. Apple employee Brian McGhie found a small flaw and wrote me the following letter:
  370.  
  371. The question was asked, How can I find out which line of a field a user has
  372. clicked in? The response was a method that would work in static fields, and
  373. then further developed into a method for scrolling fields. The function
  374. Clickline as given for scrolling windows only works if the scrolling field is
  375. (in pixels) an integer multiple of the textheight. A corrected version of
  376. Clickline appears below.
  377.  
  378. Function Clickline
  379.      return (trunc(((scroll of the target) 
  380.      + (item two of the clickloc) 
  381.      - (item two of the rect of the target)) 
  382.      div the textheight of the target) + one)
  383. End Clickline
  384.  
  385. The idea is to calculate the number of pixels from the top of the field to the
  386. position that you clicked on. So you take the number of pixels that have
  387. scrolled offscreen, and add in the vertical position of the mouseclick minus
  388. the vertical position of the top of the field. This sum is the total number of
  389. pixels from the logical top of the window not the visual top. Divide by the
  390. height of the font to get the number of lines. Since this number is not always
  391. an integer, truncate it. The result is a zero based count of lines. Add one and
  392. return the correct line number that was clicked in.
  393.  
  394. ISSUE #2:
  395.  
  396. Robin Shank provided us with a How to Program FunctionKeys in HyperTalk
  397. script. We left out a word, and the script will not work without it.  The
  398. script should read:
  399.  
  400. On functionkey whatkey
  401.    if whatkey is 6 then
  402.    type x with commandkey   Cut whatever is selected
  403.    domenu background        enter the background
  404.    type v with commandkey   Paste it
  405.    domenu background        leave the background
  406.      else
  407.         pass functionkey
  408.      end if
  409. end functionkey
  410.  
  411. We hope you have enjoyed reading WINDOID and have found it to be interesting
  412. and informative. We care enough to take the time to give you the most
  413. up-to-date information about HyperCard, and we would like to make a request for
  414. a little of your time. There is a form that follows this editorial; please fill
  415. it out if you will. We are very interested in hearing from you. What sort of
  416. stacks are you using, what kind of stacks are you creating, and what are your
  417. joys and frustrations in using HyperCard.
  418.  
  419. You have the unique opportunity to communicate directly with Bill, Dan, and the
  420. entire HyperCard development team. We really want to know what you would like
  421. to see in HyperCard and are more than willing to give you what you want. What
  422. we need to make this happen is your input. Let us know what you think. We can
  423. address it in WINDOID or perhaps the next revision of HyperCard. You can make a
  424. difference in the world by communicating with us. Dont pass up the
  425. opportunity!
  426.  
  427. The form:
  428.  
  429. Please use the following form to make a difference in the world:
  430.  
  431. Date:
  432. Name:
  433. Address:
  434. Phone #:
  435. Versions of:
  436.  a.  HyperCard:
  437.  b.  Associated software:
  438.  c.  System Software:
  439.    1. System
  440.    2. Finder
  441.    3. ImageWriter file
  442.    4. LaserWriter file
  443.    5. Any others
  444. Type of Macintosh:
  445. Peripherals:
  446. Description of problem, suggestions or comments:
  447.  
  448.  
  449. Fill this out and send it to:
  450.  
  451. AHUG
  452. C/O David Leffler
  453. Apple Computer Inc.
  454. MS 27AQ
  455. 20525 Mariani Ave.,
  456. Cupertino, CA  95014
  457.  
  458. Or copy the format and AppleLink it to:
  459.  
  460. HYPERBUG$
  461.  
  462.